{include file='common/head'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>角色列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加角色','{:url(\'admin/authgroup/jiaoseadd\')}')"><i class="layui-icon"></i>添加角色</button>
        <span class="x-right" style="line-height:40px">共有数据:条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>NO</th>
            <th>标题</th>
            <th>角色描述</th>
            <th>状态</th>
            <th >操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="jiao" id="jiao"}
        <tr>
            <td>{$key+1}</td>
            <td>{$jiao.jname}</td>
            <td>{$jiao.describe}</td>
            <td>{if $jiao.status==1}正常{else/}锁定{/if}</td>
            {if $jiao.id!=1}
            <td class="td-manage">
                <a title="编辑" onclick="banner_edit(this,'')" attr_id='{$jiao.id}' href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>编辑
                </a>
                {if $jiao.status==1}
                <a title="禁用" onclick="member_jin(this,'{$jiao.id}')" attr_id='' href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>禁用
                </a>{else/}
                <a title="启用" onclick="member_qi(this,'{$jiao.id}')" attr_id='' href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>启用
                </a>{/if}
                <a title="设置权限" onclick="banner_set(this)" attr_id='{$jiao.id}' href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>设置权限
                </a>
            </td>{else/}
            <td>
                <button class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger">超级管理员拥有最高权限</button>
            </td>{/if}
        </tr>
        {/volist}
        </tbody>
    </table>
    <!--<div class="page">-->
        <!--<div>-->
        <!--</div>-->
    <!--</div>-->

</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    //管理员禁用
    function member_jin(obj,id){
        //发异步删除数据
        $.ajax({
            url:"{:URL('authgroup/jin')}",
            data:{"id":id},
            type:"post",
            dataType:'json',
            success:function(msg){
                if(msg==1){
                    layer.msg("禁用成功！",{icon: 6},function () {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口

                    });
                    return false;

                }else{
                    layer.msg("失败！",{icon: 5},function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        // 关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口
                    });
                    return false;
                }
            }
        })
        return false;
    }
    //管理员启用
    function member_qi(obj,id){
        //发异步删除数据
        $.ajax({
            url:"{:URL('authgroup/qi')}",
            data:{"id":id},
            type:"post",
            dataType:'json',
            success:function(msg){
                if(msg==1){
                    layer.msg("启用成功！",{icon: 6},function () {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口

                    });
                    return false;

                }else{
                    layer.msg("失败！",{icon: 5},function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        // 关闭当前frame
                        window.location.reload();//刷新父级窗口
                    });
                    return false;
                }
            }
        })
    }
  
   /*角色-修改*/
	function banner_edit(obj){
				
				var mid=$(obj).attr('attr_id');
				var url='{:URL('authgroup/update')}?id='+mid;
				//alert(url);
				x_admin_show('修改用户',url) 
	
		}

   /*给角色设置权限*/
	function banner_set(obj){
			
				var mid=$(obj).attr('attr_id');
				//alert(mid);
				var url='{:URL('authgroup/setquan')}?id='+mid;
				//alert(url);
				x_admin_show('设置权限',url) 
		}
</script>

</body>

</html>